package com.taoye.thread;

public class Demo16 {
	public static void main(String[] args) {
		Demo16Thread t = new Demo16Thread();
		Thread s1 = new Thread(t);
		s1.setName("A");
		Thread s2 = new Thread(t);
		s2.setName("B");
		Thread s3 = new Thread(t);
		s3.setName("C");
		s1.start();
		s2.start();
		s3.start();
	}
}

class Demo16Thread extends Thread {
	private int count = 0;

	@Override
	public void run() {
		System.out.println("线程" + Thread.currentThread().getName() + "执行了run方法:"+System.currentTimeMillis());
		if (Thread.currentThread().getName().equals("A")) {
			Thread.yield();
			System.out.println("A线程礼让了");
		}

		if (Thread.currentThread().getName().equals("B")) {
			Thread.yield();
			System.out.println("B线程礼让了");
		}
		System.out.println("线程" + Thread.currentThread().getName() + "执行了累加，当前数字：" +System.currentTimeMillis());
	}
}